<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="cn.jdy.framework.util.IpUtil"%>
<%
	String ip = IpUtil.getIp(request);// 访问者IP
	request.setAttribute("ipaddress", ip);
%>
<!DOCTYPE html>

<html lang="en" class="no-js">

<head>
<jsp:include page="../common/common.jsp" />
</head>
<body class="page-header-fixed">
	<jsp:include page="../common/header.jsp" />
	<div class="clearfix"></div>
	<div class="page-container">
		<div class="page-sidebar-wrapper"><jsp:include
				page="../common/menu.jsp" /></div>
		<div class="page-content-wrapper">
			<div class="page-content">
				<div class="row">
					<div class="col-md-12">
						<form class="form-horizontal form-row-seperated" id="form"
							method="post" action="${path}/lhkgajcolumns/save">
							<div class="portlet box purple">
								<div class="portlet-title">
									<div class="caption">
										<i class="fa fa-shopping-cart"></i>储位详细内容
									</div>
									<div class="actions btn-set">
									
										<input class="btn default" type="button" value="取消"
											onclick="javascript:history.go(-1);">
									<%-- 	<c:choose>
											<c:when test="${data.topTime=='0'||data.topTime==null}">
												<button type="button" onclick="saveDz()"
													class="btn  btn-success">
													<i class="fa icon-flag"></i> 顶置
												</button>
											</c:when>
											<c:otherwise>
												<button type="button" onclick="saveRmdz()"
													class="btn btn-info">
													<i class="fa  icon-repeat"></i> 取消顶置
												</button>
											</c:otherwise>
										</c:choose>  --%>
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>
									</div>
								</div>
								<div class="portlet-body">
									<div class="tabbable">
										<div class="tab-content no-space">
											<div class="tab-pane active" id="tab_general">
												<div class="form-body">
													<div class="form-group">
														<label class="col-md-2 control-label">储位编号: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value1" name="value1"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value1}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">储位名称: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value2" name="value2"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value2}" />
														</div>
													</div>
<!-- 													<div class="form-group"> -->
<!-- 														<label class="col-md-2 control-label">公开属性: <span -->
<!-- 															class="required">*</span> -->
<!-- 														</label> -->
<!-- 														<div class="col-md-3"> -->
<!-- 															<select name="status" class="form-control"> -->
<!-- 																<option value="7" -->
<!-- 																	<c:if test="${7== data.status }">selected="selected" </c:if>>不予公开</option> -->
<!-- 																<option value="5" -->
<!-- 																	<c:if test="${5== data.status }">selected="selected" </c:if>>主动公开</option> -->
<!-- 																<option value="6" -->
<!-- 																	<c:if test="${6== data.status }">selected="selected" </c:if>>依申请公开</option> -->
<!-- 																<option value="0" -->
<!-- 																	<c:if test="${0== data.status }">selected="selected" </c:if>>无效</option> -->
<!-- 															</select> -->
<!-- 														</div> -->
<!-- 													</div> -->
													
													<div class="form-group">
														<label class="col-md-2 control-label">记录时间: </label>

														<div class="col-md-5">
															<input id="falseCreateTime" name="falseCreateTime"
																type="text" class="form-control tags medium"
																value="${data.falseCreateTime}"
																onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">规格型号: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value3" name="value3"
																class="form-control measure-input" 
																value="${data.value3}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">技术参数: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value4" name="value4"
																class="form-control measure-input" 
																value="${data.value4}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">生产厂家: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value5" name="value5"
																class="form-control measure-input" 
																value="${data.value5}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">最低库存: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value6" name="value6"
																class="form-control measure-input" 
																value="${data.value6}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">最高库存: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value7" name="value7"
																class="form-control measure-input" 
																value="${data.value7}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">备注: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															 <textarea id="value8" name="value8"
                                                               class="form-control tags medium" style="height: 200px ! important;width: 600px ! important;"
                                                               >${data.value8}</textarea>
														</div>
													</div>
												<%-- 	<div class="form-group">
														<label class="col-md-2 control-label">URL: </label>

														<div class="col-md-5">
															<input id="isURL" name="isURL" type="text"
																class="form-control tags medium" value="${data.isURL}" />
														</div>
													</div>
													
													<div class="form-group">
                                                    <label class="col-md-2 control-label">投稿人:    
                                                    </label>
                                                     <div class="col-md-3">
                                                  <select id="department" name="department" class="form-control">
                                                  <option value="">当前用户 </option>
                                                    <c:forEach items="${deptList}" var="d">
                                                            <option value="${d.value3 }"<c:if test="${d.value3==data.department }">selected="selected"</c:if>>${d.value0}</option>
                                                        </c:forEach>
                                                        </select></div>
                                                </div>
													<div class="form-group">
														<label class="col-md-2 control-label">内容: <span
															class="required">*</span>
														</label>

														<div class="col-md-8">
															<input id="context" type="hidden" name="context">
															<script id="editor" type="text/plain"
																style="height:500px;">${data.context}</script>
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">签收单位: <span
															class="required">*</span>
														</label>
														<script type="text/javascript">
															//全选 全不选
															function selectAll() {
																if ($(
																		"#SelectAll")
																		.attr(
																				"checked")) {
																	$(
																			":checkbox")
																			.attr(
																					"checked",
																					true);
																} else {
																	$(
																			":checkbox")
																			.attr(
																					"checked",
																					false);
																}
															}

															//获取所有老河口的签收单位
															$(function() {
																var dwsName = '${data.signDepartment}';
																$
																		.ajax({
																			url : _path
																					+ "/userColumn/listDjQsdw",
																			type : "POST",
																			dataType : "json",
																			async : false,
																			success : function(
																					jsonMap) {
																				var list = jsonMap.dataList;
																				$(
																						"#dwInfo")
																						.html(
																								"");
																				if (list.length > 0) {
																					if (null == dwsName) { //添加时获取所有单位
																						for (var i = 0; i < list.length; i++) {
																							var dw = list[i];
																							var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"
																									+ dw.value0
																									+ "</label>&nbsp;&nbsp;";
																							$(
																									"#dwInfo")
																									.append(
																											dInfo);
																						}
																					} else { //修改时 比对判断单位是否被选中
																						for (var i = 0; i < list.length; i++) {
																							var dw = list[i];
																							var names = dwsName
																									.split(";");
																							var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"
																									+ dw.value0
																									+ "</label>&nbsp;&nbsp;";
																							for (var j = 0; j < names.length; j++) {
																								var localDw = names[j];
																								if (dw.value3 == localDw) {
																									dInfo = "<label><input type='checkbox' name='ck' checked value="+dw.value3+">"
																											+ dw.value0
																											+ "</label>&nbsp;&nbsp;";
																								}
																							}
																							$(
																									"#dwInfo")
																									.append(
																											dInfo);
																						}
																					}

																				}
																			}
																		});
															});

															var cnt = 49;
															var radiostate = 0;
															function radioChangeRed() {
																if (radiostate == 1) {
																	document
																			.getElementById('isRed').checked = false;
																	radiostate = 0;
																} else {
																	document
																			.getElementById('isRed').checked = true;
																	radiostate = 1;
																}
															}
															function radioChangeNews() {
																if (radiostate == 1) {
																	document
																			.getElementById('isNews').checked = false;
																	radiostate = 0;
																} else {
																	document
																			.getElementById('isNews').checked = true;
																	radiostate = 1;
																}
															}
														</script>
														<div class="col-md-3" style="width:640px;">
															<div style="float: left;">
																<span style="color:red;font-size: 18px;">【全选】</span> <label>
																	<input type="checkbox" id="SelectAll"
																	onclick="selectAll();">
																</label><br>
																<div style="float:left;" id="dwInfo"></div>
															</div>

														</div>--%>
													</div>
												</div>
											</div>
										</div>
									</div>
							

								<div class="portlet-title">
									<div class="actions btn-set">
										<input class="btn default" type="button" value="取消"
											onclick="javascript:history.go(-1);">
									<%-- 	<c:choose>
											<c:when test="${data.topTime=='0'||data.topTime==null}">
												<button type="button" onclick="saveDz()"
													class="btn  btn-success">
													<i class="fa icon-flag"></i> 顶置
												</button>
											</c:when>
											<c:otherwise>
												<button type="button" onclick="saveRmdz()"
													class="btn btn-info">
													<i class="fa  icon-repeat"></i> 取消顶置
												</button>
											</c:otherwise>
										</c:choose>  --%>
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>
									</div>
								</div>
							</div>
							<input type="hidden" id="id" name="id" value="${data.id}">
							<input type="hidden" id=iscolums name="iscolums" value="${data.iscolums==null?1:data.iscolums}"> 
							<input type="hidden" id=iseverymouth name="iseverymouth" value="${data.iseverymouth==null?0:data.iseverymouth}">
							<input type="hidden" id=columnId name="columnId" value="${data.columnId==null?10654:data.columnId}"> 
							<input type="hidden" name="topTime" id="topTime" value="${data.topTime==null?0:data.topTime}" /> 
							<input type="hidden" name="readTimes" id="readTimes" value="${data.readTimes}" /> <input type="hidden" id="zisNews" name="isNews" value="${data.isNews==null?1:data.isNews}" /> 
							<input type="hidden" id="teams" name="teams" value="${ipaddress}" />
							<input type="hidden" name="isarticle"  id="isarticle"  value="0"  /> 
							<input type="hidden" id="username" name="username" value="${user.username}">
							<input type="hidden" id="summary" name="summary" value="${user.username}">
							<c:if test="${data.signStatus!=null}">
								<input type="hidden" name="signStatus" id="signStatus"
									value="${data.signStatus}" />
							</c:if>
							<input type="hidden" id="signDepartment" name="signDepartment">
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<jsp:include page="../common/footer.jsp" />
	<script type="text/javascript"
		src="${path}/assets/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
	<script type="text/javascript"
		src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/ueditor.config.js"></script> -->
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/ueditor.all.min.js"></script> -->
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/lang/zh-cn/zh-cn.js"></script> -->
	<script type="text/javascript"
		src="${path}/assets/plugins/district/linkagesel-min.js"></script>
	<script type="text/javascript" src="${path}/operate/js/topDz.js"></script>
	<script>
		var operType = '${operType}';
		var editor, form;

		//UE.getEditor('editor');
		form = $("form").Validform({
			tiptype : function(msg, o, cssctl) {
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if (!o.obj.is("form")) {//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip = o.obj.siblings(".Validform_checktip");
					cssctl(objtip, o.type);
					objtip.text(msg);
				} else {
					var objtip = o.obj.find("#msgdemo");
					cssctl(objtip, o.type);
					objtip.text(msg);
				}
			},
			postonce : true,
			showAllError : true,
			callback : function() {
				save();
			}
		});
		function save() {
// 			var context = UE.getEditor('editor').getContent();
// 			if (!/[\w\W]+/.test(context)) {
// 				alert("内容不能为空");
// 				return;
// 			}
// 			$("#context").val(context);

// 			获取签收单位	
// 			var qsdw = "";
// 			var ckValues = document.getElementsByName("ck");
// 			for (var i = 0; i < ckValues.length; i++) {
// 				if (ckValues[i].checked == true) {
// 					qsdw = qsdw + ckValues[i].value + ";";
// 				}
// 			}

// 			alert("当前签收单位"+qsdw);

// 			if (qsdw != "") {
// 				$("#signDepartment").val(qsdw);
// 			}

			//         $("#form").submit();
			//form提交 
			App.ajax(_path + "/lhkgajcolumns/save", $("form").serialize(),
					function(data) {
						if (data.statusCode == 200) {
							App.bubble(200, "更新成功！");
							window.setTimeout(function() {
								//window.close();//修改成功，弹出新页面，直接关闭
								history.go(-1);
							}, 400);
						} else if (data.statusCode == 100) {
							App.bubble(100, "添加成功！");
							window.setTimeout(function() {
								history.go(-1);//返回上一级
								//window.close();
							}, 400);
						} else {
							App.bubble(500, "信息失败！");
							// alert("信息失败")
						}
					});

		}
	</script>
</body>
</html>